import requests from "@/api/request";
import mockRequest from "@/api/mockRequest";

//三级联动接口
// /api/product/getBaseCategoryList GET 无参数
export const reqCategoryList = () => {
    return requests({
        method: "GET",
        url: "/product/getBaseCategoryList",
    });
};

//获取轮播图的api
export const reqGetBannerList = () => {
    return mockRequest({
        method: "GET",
        url: "/banner",
    });
};

//获取floor数据
export const reqFloorList = () => {
    return mockRequest({
        method: "GET",
        url: "/floor",
    });
};

//搜索模块的数据 /api/list POST
export const reqGetSearchInfo = (params) => {
    return requests({
        method: "POST",
        url: "/list",
        data: params,
    });
};

//获取产品详情信息 /api/item/{ skuId } GET
export const reqGoodsInfo = (skuId) => {
    return requests({
        method: "GET",
        url: `/item/${skuId}`,
    });
};

//将产品添加到购物车中（或者更新某一个产品的个数） /api/cart/addToCart/{ skuId }/{ skuNum } POST
export const reqAddOrUpdateShopCar = (skuId, skuNum) => {
    return requests({
        method: "POST",
        url: `/cart/addToCart/${skuId}/${skuNum}`,
    });
};

//获取购物车列表数据接口  /api/cart/cartList GET
export const reqCarList = () => {
    return requests({
        method: "GET",
        url: "/cart/cartList",
    });
};

//删除购物产品 /api/cart/deleteCart/{skuId} DELETE
export const reqDeleteCarById = (skuId) => {
    return requests({
        method: "DELETE",
        url: `/cart/deleteCart/${skuId}`,
    });
};

//修改商品选中状态 /api/cart/checkCart/{skuId}/{isChecked} GET
export const reqUpdateCheckedById = (skuId, isChecked) => {
    return requests({
        method: "GET",
        url: `/cart/checkCart/${skuId}/${isChecked}`,
    });
};

//获取验证码 /api/user/passport/sendCode/{phone} GET
export const reqGetCode = (phone) => {
    return requests({
        method: "GET",
        url: `/user/passport/sendCode/${phone}`,
    });
};

//注册 /api/user/passport/register POST
export const reqUserRegister = (data) => {
    return requests({
        method: "POST",
        url: "/user/passport/register",
        data,
    });
};

//登录  /api/user/passport/login POST
export const reqUserLogin = (data) => {
    return requests({
        method: "POST",
        url: "/user/passport/login",
        data,
    });
};

//获取用户信息【要带token】  /api/user/passport/auth/getUserInfo GET
export const reqUserInfo = () => {
    return requests({
        method: "GET",
        url: "/user/passport/auth/getUserInfo",
    });
};

//退出登录 /api/user/passport/logout GET
export const reqLogOut = () => {
    return requests({
        method: "GET",
        url: "/user/passport/logout",
    });
};

//获取用户地址信息  /api/user/userAddress/auth/findUserAddressList GET
export const reqAddressInfo = () => {
    return requests({
        method: "GET",
        url: "/user/userAddress/auth/findUserAddressList",
    });
};

//获取商品清单   /api/order/auth/trade GET
export const reqOrderInfo = () => {
    return requests({
        method: "GET",
        url: "/order/auth/trade",
    });
};

//提交订单  /api/order/auth/submitOrder?tradeNo={tradeNo} POST
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({
        method: "POST",
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        data,
    });
};

//获取支付信息 /api/payment/weixin/createNative/{orderId} GET
export const reqPayInfo = (orderId) => {
    return requests({
        method: "GET",
        url: `/payment/weixin/createNative/${orderId}`,
    });
};

//获取订单状态 /api/payment/weixin/queryPayStatus/{orderId} GET
export const reqPayStatus = (orderId) => {
    return requests({
        method: "GET",
        url: `/payment/weixin/queryPayStatus/${orderId}`,
    });
};

//获取个人中心的数据  /api/order/auth/{page}/{limit} GET
export const reqMyOrderList = (page, limit) => {
    return requests({
        method: "GET",
        url: `/order/auth/${page}/${limit}`,
    });
};